class Queue {
  constructor() {
    this.count = 0
    this.lowerCount = 0,
    this.items = {}
  }
  // 入队
  enQueue(element) {
    this.items[this.count] = element
    this.count++
  }
  // 出队
  deQueue() {
    if (this.isEmpty()) {
      return undefined
    }
    const result = this.items[this.lowerCount]
    delete this.items[this.lowerCount]
    this.lowerCount++
    return result
  }
  // 查看
  peek() {
    if (this.isEmpty()) {
      return undefined
    }
    return this.items[this.lowerCount]
  }
  // 清空
  clear() {
    this.count = 0
    this.lowerCount = 0
    this.items = {}
  }
  // 判空
  isEmpty() {
    return this.count - this.lowerCount === 0
  }
  // 长度
  size() {
    return this.count - this.lowerCount
  }
  // 转字符串
  toString() {
    if (this.isEmpty()) {
      return ''
    }
    let objString = `${this.items[this.lowerCount]}`
    for (let i = this.lowerCount + 1; i < this.count; i++) {
      objString = `${objString}, ${this.items[i]}`
    }
    return objString
  }
}
const log = console.log.bind(console)
let que = new Queue()
que.enQueue('李龙生')
que.enQueue('张三')
que.enQueue('李四')
let queStr = que.toString()
log(queStr, 'queStr')
log(que.size(), 'queSize')
log(que.items, 'que')
log(que.count, 'count')